<?php

namespace app\admin\controller\fas;

use app\common\controller\Backend;

use PhpOffice\PhpSpreadsheet\Reader\Xls;
use PhpOffice\PhpSpreadsheet\Reader\Xlsx;
use think\Db;
use think\Exception;
use think\Session;
use app\admin\model\AuthGroup;
use app\admin\model\AuthGroupAccess;
/**
 * 资产申请单管理
 *
 * @icon fa fa-circle-o
 */
class Zcorder extends Backend
{
    
    /**
     * Zcorder模型对象
     * @var \app\admin\model\fas\Zcorder
     */
    protected $model = null;

    protected $noNeedRight = ['zctypeselect', 'getzctypeselect', 'zcdeviceselect', 'getdeviceselect'];
    const ZCTYPE_ID = "__zctypeid__";

    public function _initialize()
    {
        parent::_initialize();
        $this->model = new \app\admin\model\fas\Zcorder;
        $this->view->assign("cgstateList", $this->model->getCgstateList());
        $this->view->assign("dbstateList", $this->model->getDbstateList());
        $this->view->assign("stateList", $this->model->getStateList());
        $this->view->assign("ysstateList", $this->model->getYsstateList());

        $iscg = 0;
        $isdiao = 0;
        $isys = 0;
        $ishenhe = 0;
        $authGroupList = AuthGroupAccess::where('uid', $this->auth->id)->field('uid,group_id')->select();
        foreach ($authGroupList as $row) {
            switch($row->group_id) {
                default:
                    break;
                case 1:
                    //admin
                    $iscg = 1;
                    $isdiao = 1;
                    $isys = 1;
                    $ishenhe = 1;
                    break;
                case 6:
                    //固定资产管理员
                    break;
                case 7:
                    //普通
                    break;
                case 8:
                    //审核
                    $ishenhe = 1;
                    break;
                case 9:
                    //资产负责人
                    break;
                case 10:
                    //保养工人
                    break;
                case 11:
                    //维修工人
                    break;
                case 12:
                    //采购人员
                    $iscg = 1;
                    break;
                case 13:
                    //调拨员
                    $isdiao = 1;
                    break;
                case 14:
                    //验收人员
                    $isys = 1;
                    break;
            }

        }
        $this->assignconfig('iscg', $iscg);
        $this->assignconfig('isys', $isys);
        $this->assignconfig('isdiao', $isdiao);
        $this->assignconfig('ishenhe', $ishenhe);

//        $this->assignconfig('shenhe', $this->auth->check('fas/zcdevice/shenhe'));

    }
    
    /**
     * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
     * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
     * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
     */
    

    /**
     * 查看
     */
    public function index()
    {
        //当前是否为关联查询
        $this->relationSearch = true;
        //设置过滤方法
        $this->request->filter(['strip_tags', 'trim']);
        if ($this->request->isAjax())
        {
            //如果发送的来源是Selectpage，则转发到Selectpage
            if ($this->request->request('keyField'))
            {
                return $this->selectpage();
            }
            list($where, $sort, $order, $offset, $limit) = $this->buildparams();
            $total = $this->model
                    ->with(['zctype'])
                    ->where($where)
                    ->order($sort, $order)
                    ->count();

            $list = $this->model
                    ->with(['zctype'])
                    ->where($where)
                    ->order($sort, $order)
                    ->limit($offset, $limit)
                    ->select();

            foreach ($list as $row) {
                
                
            }
            $list = collection($list)->toArray();
            $result = array("total" => $total, "rows" => $list);

            return json($result);
        }
        return $this->view->fetch();
    }

    /**
     * 添加
     */
    public function add()
    {
        if ($this->request->isPost()) {
            $params = $this->request->post("row/a");
            if ($params) {
                $params = $this->preExcludeFields($params);

                if ($this->dataLimit && $this->dataLimitFieldAutoFill) {
                    $params[$this->dataLimitField] = $this->auth->id;
                }
                $result = false;
                Db::startTrans();
                try {
                    //是否采用模型验证
                    if ($this->modelValidate) {
                        $name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
                        $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate;
                        $this->model->validateFailException(true)->validate($validate);
                    }

                    $params['diaobo_ids'] = "";
                    //生成调拨单
                    if (strlen($params['zcdevice_ids']) > 0) {
                        $zcdevicelist = \app\admin\model\fas\Zcdevice::where("id", "in", "{$params['zcdevice_ids']}")->select();
                        foreach ($zcdevicelist as &$row2) {
                            $zl = new \app\admin\model\fas\Zcdiaobojl;
                            $zl->zcdevice_id = $row2->id;
                            $zl->sydw = $params['sqdw'];
                            $zl->sydd = $params['sydd'];
                            $zl->fgroup = $params['fgroup'];
                            $zl->ffactory = $params['ffactory'];
                            $zl->sydw0 = $row2->sydw;
                            $zl->sydd0 = $row2->sydd;
                            $zl->fgroup0 = $row2->fgroup;
                            $zl->ffactory0 = $row2->ffactory;
                            $zl->fzr0 = $row2->fzr;
                            $zl->sqr = "资产申请单";//$this->model->id."";//申请人 --- zcorder id
                            $zl->save();

                            $params['diaobo_ids'] .= $zl->id.",";
                            $row2->state = '2';
                            $row2->save();
                        }

                        if (strlen($params['diaobo_ids']) > 1) {
                            // 去最后的逗号
                            $params['diaobo_ids'] = substr($params['diaobo_ids'], 0, -1);
                        }
                    }

                    $params['sqadmin_id'] = $this->auth->id;
                    $ys = model('Admin')->get($params['ysadmin_id']);
                    if ($ys) {
                        $params['ysmanager'] = $ys->nickname;
                    }
                    $cg = model('Admin')->get($params['cgadmin_id']);
                    if ($cg) {
                        $params['cgmanager'] = $cg->nickname;
                    }
                    $diao = model('Admin')->get($params['dbadmin_id']);
                    if ($diao) {
                        $params['dbmanager'] = $diao->nickname;
                    }

                    $result = $this->model->allowField(true)->save($params);
                    Db::commit();

                } catch (ValidateException $e) {
                    Db::rollback();
                    $this->error($e->getMessage());
                } catch (PDOException $e) {
                    Db::rollback();
                    $this->error($e->getMessage());
                } catch (Exception $e) {
                    Db::rollback();
                    $this->error($e->getMessage());
                }
                if ($result !== false) {
                    $this->success();
                } else {
                    $this->error(__('No rows were inserted'));
                }
            }
            $this->error(__('Parameter %s can not be empty', ''));
        }

        $row = array(
            "fgroup" => "",
            "ffactory" => "",
            "sqdw" => "",
            "sydd" => "",
        );
        $zh = model('Admin')->get($this->auth->id);

        $row['fgroup'] = $zh->fgroup;
        $row['ffactory'] = $zh->ffactory;
        $row['sqdw'] = $zh->sydw;
        $row['sydd'] = $zh->sydd;

        $this->view->assign("row", $row);

        return $this->view->fetch();
    }


    /**
     * 编辑
     */
    public function edit($ids = null)
    {
        $row = $this->model->get($ids);
        if (!$row) {
            $this->error(__('No Results were found'));
        }
        $adminIds = $this->getDataLimitAdminIds();
        if (is_array($adminIds)) {
            if (!in_array($row[$this->dataLimitField], $adminIds)) {
                $this->error(__('You have no permission'));
            }
        }
        if ($this->request->isPost()) {
            $params = $this->request->post("row/a");
            if ($params) {
                $params = $this->preExcludeFields($params);
                $result = false;
                Db::startTrans();
                try {
                    //是否采用模型验证
                    if ($this->modelValidate) {
                        $name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
                        $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
                        $row->validateFailException(true)->validate($validate);
                    }
                    $params['sqadmin_id'] = $this->auth->id;
                    $ys = model('Admin')->get($params['ysadmin_id']);
                    if ($ys) {
                        $params['ysmanager'] = $ys->nickname;
                    }
                    $cg = model('Admin')->get($params['cgadmin_id']);
                    if ($cg) {
                        $params['cgmanager'] = $cg->nickname;
                    }
                    $diao = model('Admin')->get($params['dbadmin_id']);
                    if ($diao) {
                        $params['dbmanager'] = $diao->nickname;
                    }

                    $result = $row->allowField(true)->save($params);
                    Db::commit();
                } catch (ValidateException $e) {
                    Db::rollback();
                    $this->error($e->getMessage());
                } catch (PDOException $e) {
                    Db::rollback();
                    $this->error($e->getMessage());
                } catch (Exception $e) {
                    Db::rollback();
                    $this->error($e->getMessage());
                }
                if ($result !== false) {
                    $this->success();
                } else {
                    $this->error(__('No rows were updated'));
                }
            }
            $this->error(__('Parameter %s can not be empty', ''));
        }


        if (strlen($row["gsdate"]) < 2) {
            $row["gsdate"] = date("Y-m-d");
        }
        $this->view->assign("row", $row);
        $zcdevicenames = "";
        $devicelist = \app\admin\model\fas\Zcdevice::where("id", "in", $row->zcdevice_ids)->select();
        foreach ($devicelist as $row1) {
            $zcdevicenames .= $row1->name." [".$row1->ffactory."|".$row1->sydw."|".$row1->sydd."]\n";
        }
        $this->view->assign("zcdevicenames", $zcdevicenames);
        return $this->view->fetch();
    }


    /**
     * 调拨
     */
    public function diaobo($ids = null)
    {
        $row = $this->model->get($ids);
        if (!$row) {
            $this->error(__('No Results were found'));
        }
        $adminIds = $this->getDataLimitAdminIds();
        if (is_array($adminIds)) {
            if (!in_array($row[$this->dataLimitField], $adminIds)) {
                $this->error(__('You have no permission'));
            }
        }
        if ($this->request->isPost()) {
            $params = $this->request->post("row/a");
            if ($params) {
                $params = $this->preExcludeFields($params);
                $result = false;
                Db::startTrans();
                try {
                    //是否采用模型验证
                    if ($this->modelValidate) {
                        $name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
                        $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
                        $row->validateFailException(true)->validate($validate);
                    }
                    $result = $row->allowField(true)->save($params);
                    Db::commit();
                } catch (ValidateException $e) {
                    Db::rollback();
                    $this->error($e->getMessage());
                } catch (PDOException $e) {
                    Db::rollback();
                    $this->error($e->getMessage());
                } catch (Exception $e) {
                    Db::rollback();
                    $this->error($e->getMessage());
                }
                if ($result !== false) {
                    $this->success();
                } else {
                    $this->error(__('No rows were updated'));
                }
            }
            $this->error(__('Parameter %s can not be empty', ''));
        }


        if (strlen($row["gsdate"]) < 2) {
            $row["gsdate"] = date("Y-m-d");
        }

        $zcdevicenames = "";
        $devicelist = \app\admin\model\fas\Zcdevice::where("id", "in", $row->zcdevice_ids)->select();
        foreach ($devicelist as $row1) {
            $zcdevicenames .= $row1->name." [".$row1->ffactory."|".$row1->sydw."|".$row1->sydd."]\n";
        }
        $this->view->assign("zcdevicenames", $zcdevicenames);
        $this->view->assign("row", $row);

        return $this->view->fetch();
    }


    /**
     * 采购
     */
    public function caigou($ids = null)
    {
        $row = $this->model->get($ids);
        if (!$row) {
            $this->error(__('No Results were found'));
        }
        $adminIds = $this->getDataLimitAdminIds();
        if (is_array($adminIds)) {
            if (!in_array($row[$this->dataLimitField], $adminIds)) {
                $this->error(__('You have no permission'));
            }
        }
        if ($this->request->isPost()) {
            $params = $this->request->post("row/a");
            if ($params) {
                $params = $this->preExcludeFields($params);
                $result = false;
                Db::startTrans();
                try {
                    //是否采用模型验证
                    if ($this->modelValidate) {
                        $name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
                        $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
                        $row->validateFailException(true)->validate($validate);
                    }
                    if (isset($params['cgstate']) && $params['cgstate'] == '2' && $params['cgstate'] != $row->cgstate) {
                        //采购已完成
                        $params['rukudate'] = date("Y-m-d");
                    }
                    $result = $row->allowField(true)->save($params);
                    Db::commit();


                } catch (ValidateException $e) {
                    Db::rollback();
                    $this->error($e->getMessage());
                } catch (PDOException $e) {
                    Db::rollback();
                    $this->error($e->getMessage());
                } catch (Exception $e) {
                    Db::rollback();
                    $this->error($e->getMessage());
                }
                if ($result !== false) {
                    $this->success();
                } else {
                    $this->error(__('No rows were updated'));
                }
            }
            $this->error(__('Parameter %s can not be empty', ''));
        }

        $this->view->assign("row", $row);
        $zcdevicenames = "";
        $devicelist = \app\admin\model\fas\Zcdevice::where("id", "in", $row->zcdevice_ids)->select();
        foreach ($devicelist as $row1) {
            $zcdevicenames .= $row1->name." [".$row1->ffactory."|".$row1->sydw."|".$row1->sydd."]\n";
        }
        $this->view->assign("zcdevicenames", $zcdevicenames);
        return $this->view->fetch();
    }

    /**
     * 检验
     */
    public function check($ids = null)
    {
        $row = $this->model->get($ids);
        if (!$row) {
            $this->error(__('No Results were found'));
        }
        $adminIds = $this->getDataLimitAdminIds();
        if (is_array($adminIds)) {
            if (!in_array($row[$this->dataLimitField], $adminIds)) {
                $this->error(__('You have no permission'));
            }
        }
        if ($this->request->isPost()) {
            $params = $this->request->post("row/a");
            if ($params) {
                $params = $this->preExcludeFields($params);
                $result = false;
                Db::startTrans();
                try {
                    //是否采用模型验证
                    if ($this->modelValidate) {
                        $name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
                        $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
                        $row->validateFailException(true)->validate($validate);
                    }
                    if (isset($params['ysstate']) && $params['ysstate'] == '1' && $params['ysstate'] != $row->ysstate) {
                        //检验已完成
                        $params['ysdate'] = date("Y-m-d");
                    }
                    $result = $row->allowField(true)->save($params);
                    Db::commit();
                } catch (ValidateException $e) {
                    Db::rollback();
                    $this->error($e->getMessage());
                } catch (PDOException $e) {
                    Db::rollback();
                    $this->error($e->getMessage());
                } catch (Exception $e) {
                    Db::rollback();
                    $this->error($e->getMessage());
                }
                if ($result !== false) {
                    $this->success();
                } else {
                    $this->error(__('No rows were updated'));
                }
            }
            $this->error(__('Parameter %s can not be empty', ''));
        }


        if (strlen($row["gsdate"]) < 2) {
            $row["gsdate"] = date("Y-m-d");
        }
        $this->view->assign("row", $row);
        $zcdevicenames = "";
        $devicelist = \app\admin\model\fas\Zcdevice::where("id", "in", $row->zcdevice_ids)->select();
        foreach ($devicelist as $row1) {
            $zcdevicenames .= $row1->name." [".$row1->ffactory."|".$row1->sydw."|".$row1->sydd."]\n";
        }
        $this->view->assign("zcdevicenames", $zcdevicenames);
        return $this->view->fetch();
    }


    /**
     * 终审
     */
    public function shenhe($ids = null)
    {
        $row = $this->model->get($ids);
        if (!$row) {
            $this->error(__('No Results were found'));
        }
        $adminIds = $this->getDataLimitAdminIds();
        if (is_array($adminIds)) {
            if (!in_array($row[$this->dataLimitField], $adminIds)) {
                $this->error(__('You have no permission'));
            }
        }
        if ($this->request->isPost()) {
            $params = $this->request->post("row/a");
            if ($params) {
                $params = $this->preExcludeFields($params);
                $result = false;
                Db::startTrans();
                try {
                    //是否采用模型验证
                    if ($this->modelValidate) {
                        $name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
                        $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
                        $row->validateFailException(true)->validate($validate);
                    }

                    if ($row->state == '2' && strlen($row->zcdevice_ids) > 0) {
                        $devicelist = \app\admin\model\fas\Zcdevice::where("id", "in", $row->zcdevice_ids)->select();
                        foreach ($devicelist as &$row2) {
                            $row2->state = "0";
                            $row2->save();
                        }
                    }

                    $result = $row->allowField(true)->save($params);
                    Db::commit();
                } catch (ValidateException $e) {
                    Db::rollback();
                    $this->error($e->getMessage());
                } catch (PDOException $e) {
                    Db::rollback();
                    $this->error($e->getMessage());
                } catch (Exception $e) {
                    Db::rollback();
                    $this->error($e->getMessage());
                }
                if ($result !== false) {
                    $this->success();
                } else {
                    $this->error(__('No rows were updated'));
                }
            }
            $this->error(__('Parameter %s can not be empty', ''));
        }


        if (strlen($row["gsdate"]) < 2) {
            $row["gsdate"] = date("Y-m-d");
        }
        $this->view->assign("row", $row);
        $zcdevicenames = "";
        $devicelist = \app\admin\model\fas\Zcdevice::where("id", "in", $row->zcdevice_ids)->select();
        foreach ($devicelist as $row1) {
            $zcdevicenames .= $row1->name." [".$row1->ffactory."|".$row1->sydw."|".$row1->sydd."]\n";
        }
        $this->view->assign("zcdevicenames", $zcdevicenames);
        return $this->view->fetch();
    }


    /**
     * 详情
     */
    public function detail($ids = null)
    {
        $row = $this->model->get($ids);
        if (!$row) {
            $this->error(__('No Results were found'));
        }
        $adminIds = $this->getDataLimitAdminIds();
        if (is_array($adminIds)) {
            if (!in_array($row[$this->dataLimitField], $adminIds)) {
                $this->error(__('You have no permission'));
            }
        }
        if ($this->request->isPost()) {
            $params = $this->request->post("row/a");
            if ($params) {
                $params = $this->preExcludeFields($params);
                $result = false;
                Db::startTrans();
                try {
                    //是否采用模型验证
                    if ($this->modelValidate) {
                        $name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
                        $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
                        $row->validateFailException(true)->validate($validate);
                    }
                    $result = $row->allowField(true)->save($params);
                    Db::commit();
                } catch (ValidateException $e) {
                    Db::rollback();
                    $this->error($e->getMessage());
                } catch (PDOException $e) {
                    Db::rollback();
                    $this->error($e->getMessage());
                } catch (Exception $e) {
                    Db::rollback();
                    $this->error($e->getMessage());
                }
                if ($result !== false) {
                    $this->success();
                } else {
                    $this->error(__('No rows were updated'));
                }
            }
            $this->error(__('Parameter %s can not be empty', ''));
        }


        if (strlen($row["gsdate"]) < 2) {
            $row["gsdate"] = date("Y-m-d");
        }
        $this->view->assign("row", $row);
        $zcdevicenames = "";
        $devicelist = \app\admin\model\fas\Zcdevice::where("id", "in", $row->zcdevice_ids)->select();
        foreach ($devicelist as $row1) {
            $zcdevicenames .= $row1->name." [".$row1->ffactory."|".$row1->sydw."|".$row1->sydd."]\n";
        }
        $this->view->assign("zcdevicenames", $zcdevicenames);
        return $this->view->fetch();
    }

    //申请单选择资产设备型体 列表--不考虑权限
    public function zctypeselect() {

        //设置过滤方法
        $this->request->filter(['strip_tags', 'trim']);
        if ($this->request->isAjax()) {
            //如果发送的来源是Selectpage，则转发到Selectpage
            if ($this->request->request('keyField')) {
                return $this->selectpage();
            }
            list($where, $sort, $order, $offset, $limit) = $this->buildparams();

            $zc = new \app\admin\model\fas\Zctype;
            $total = $zc
                ->where($where)
                ->order($sort, $order)
                ->count();

            $list = $zc
                ->where($where)
                ->order($sort, $order)
                ->limit($offset, $limit)
                ->select();

            $list = collection($list)->toArray();
            $result = array("total" => $total, "rows" => $list);

            return json($result);
        }
        return $this->view->fetch();
    }

    public function getzctypeselect($ids)
    {
        if ($this->request->isPost()) {
            $row = \app\admin\model\fas\Zctype::get($ids);
            if (!$row)
                $this->error(__('No Results were found'));

            $row->toArray();
            $this->success('success', null, $row);
        }
        $this->error(__('没有选中资产设备型号！'));

    }

    //多选闲置设备 列表--不考虑权限
    public function zcdeviceselect() {

        $zctype_id = 0;
        $url = $_SERVER['REQUEST_URI'];
        if (false !== strpos($url, '/ids/')) {
            $urls = explode('?', $url);
            $url = $urls[0];
            $urls = explode('/', $url);
            $size = count($urls);
            $zctype_id = $urls[$size - 1];
            Session::set(self::ZCTYPE_ID, $zctype_id);
        }

        //$this->loadlang('fas/zcdevice');//没用
        $this->relationSearch = true;
        //设置过滤方法
        $this->request->filter(['strip_tags', 'trim']);
        if ($this->request->isAjax())
        {
            //如果发送的来源是Selectpage，则转发到Selectpage
            if ($this->request->request('keyField'))
            {
                return $this->selectpage();
            }
            list($where, $sort, $order, $offset, $limit) = $this->buildparams();
            $zcdevice = new \app\admin\model\fas\Zcdevice;
            $total = $zcdevice
                ->with(['zctype','zcorder'])
                ->where($where)
                ->where("zcdevice.state", "1")//Zcdevice
                ->where('zcdevice.zctype_id', $zctype_id)
                ->order($sort, $order)
                ->count();

            $list = $zcdevice
                ->with(['zctype','zcorder'])
                ->where($where)
                ->where("zcdevice.state", "1")
                ->where('zcdevice.zctype_id', $zctype_id)
                ->order($sort, $order)
                ->limit($offset, $limit)
                ->select();

            foreach ($list as &$row) {
                if ($row['state'] != '4') {
                    $career =intval((time() - strtotime($row['qydate']))/(365*24*3600)) + 1;//已使用时厂-年
                    if ($career > floatval($row['sbsynx'])) {
                        $row['cz'] = "0";
                    } else {
                        $row['cz'] = intval(floatval($row['sbjz']) * (intval($row['sbsynx']) - $career) / intval($row['sbsynx']));
                    }
                }

            }
            $list = collection($list)->toArray();
            $result = array("total" => $total, "rows" => $list);

            return json($result);
        }

        $this->view->assign("zctype_id", $zctype_id);

        return $this->view->fetch();
    }

    public function getdeviceselect($ids)
    {
        if ($this->request->isPost()) {
            $list = \app\admin\model\fas\Zcdevice::where("id", "in", $ids)->select();
            if (!$list)
                $this->error(__('No Results were found'));

//            $list = collection($list)->toArray();
            $allids = "";
            $i = 0;
            $names = "";
            foreach ($list as $row) {
                if ($i == 0) {
                    $allids = $row["id"];
                    $names = $row->name." [".$row->ffactory."|".$row->sydw."|".$row->sydd."]";
                } else {
                    $allids .= ",".$row["id"];
                    $names .= "\n".$row->name." [".$row->ffactory."|".$row->sydw."|".$row->sydd."]";
                }
                $i++;
            }

            $zz = array(
                "ids"=>$allids,
                "names"=>$names,
                "num"=>$i
            );

            $this->success('success', null, $zz);
        }
        $this->error(__('没有选中设备！'));

    }

}
